class Formula {
  constructor(city) {
    this.city = city;
    return this.getCityformula(city);
  }
  // 切换城市
  getCityformula(city) {
    switch (city) {
      case "深圳":
        return new Sz();
        break;

    }
  }
}
class Sz {
  // 养老保险
  yanglao (basePayment, register){
    let yanglaoData = {};
    let person_p, comid_p;
    let yanglaoBase = (basePayment <= 2200 ? 2200 : (basePayment >= 19014 ? 19014 : basePayment));
    if (register == "深户"){
      person_p = 0.08 * yanglaoBase ;
      comid_p = 0.14 * yanglaoBase ;
    }else{
      person_p = 0.08 * yanglaoBase;
      comid_p = 0.13 * yanglaoBase;
    }
    yanglaoData = { person_p: person_p.toFixed(2), comid_p: comid_p.toFixed(2)}
    return yanglaoData;

  }

  // 医疗保险
  medicare (basePayment, level){
    let medicareBase = (basePayment <= 5509 ? 5509 : (basePayment >= 25044 ? 25044 : basePayment));
    let person_h,comid_h;
    if(level == "一档"){
      person_h = 0.02 * medicareBase;
      comid_h = 0.062 * medicareBase;
    } else if (level == "二档"){
      person_h = 0.002 * 9309;
      comid_h = 0.006 * 9309;
    }else{
      person_h = 0.001 * 9309;
      comid_h = 0.0045 * 9309;
    }

    let medicareData = { person_h:person_h.toFixed(2), comid_h:comid_h.toFixed(2)};
    return medicareData;
  }

  // 工伤保险
  injury (basePayment) {
    let injuryBase = (basePayment <= 2200 ? 2200 : (basePayment >= 27927 ? 27927 : basePayment));
    let person_e = 0;
    let comid_e = 0.00441 * injuryBase;
    let injuryData = { person_e: person_e.toFixed(2), comid_e: comid_e.toFixed(2)};
    return injuryData;
  }

  // 生育保险
  birthInsure (basePayment) {
    let birthBase = (basePayment <= 2200 ? 2200 : (basePayment >= 27927 ? 27927 : basePayment));
    let person_m = 0;
    let comid_m = 0.0045 * birthBase;
    let birthData = { person_m: person_m.toFixed(2), comid_m: comid_m.toFixed(2)};
    return birthData;
  }

  // 失业保险
  shiye (basePayment) {
    let person_u = 0.003 * basePayment;
    let comid_u = 0.007 * basePayment;
    let shiyeData = { person_u: person_u.toFixed(2), comid_u: comid_u.toFixed(2)};
    return shiyeData;
  }
}

module.exports.Formula = Formula;